import Vue from '@/main.js';






export  function getSupplierData() {
  var path = "/business/supplier/list";
  return Vue.$http.get(path)
    .then((res) => {
        return res.data.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}



export  function getManufacturerData() {
  var path = "/business/manufacturer/list";
  return Vue.$http.get(path)
    .then((res) => {
        return res.data.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}



export  function getPositionData() {
  var path = "/business/position/list";
  return Vue.$http.get(path)
    .then((res) => {
        return res.data.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}



export  function getCategoryData() {
  var path = "/business/category/list";
  return Vue.$http.get(path)
    .then((res) => {
        return res.data.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}



export  function getDictionaryData(category) {
  var path = "/business/dictionary/queryList?category="+category;
  return Vue.$http.get(path)
    .then((res) => {
        return res.data.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}



export  function insertParameter(insertForm) {
  var path = "/business/parameter/insertParameterRecord";
  return Vue.$http.post(path, {
    recordName: insertForm.recordName,
    deviceId: insertForm.deviceId,
    description: insertForm.description,
    parameterDetail: insertForm.parameterDetail,
    recordTime: insertForm.recordTime,
    
    })
    .then((res) => {
        return res;
    })
    .catch(function (error) {
      console.error(error);
    });
  }


export  function updateParameter(updateForm) {
  var path = "/business/parameter/updateParameterRecord";
  return Vue.$http.post(path, {
    id: updateForm.id,
    recordName: updateForm.recordName,
    deviceId: updateForm.deviceId,
    description: updateForm.description,
    parameterDetail: updateForm.parameterDetail,
    recordTime: updateForm.recordTime,
    
    })
    .then((res) => {
        return res;
    })
    .catch(function (error) {
      console.error(error);
    });
  }
  
  
  export  function deleteParameter(recordId) {
    var path = "/business/parameter/deleteParameterRecord?recordId="+recordId;
    return Vue.$http.get(path)
    .then((res) => {
      return res.data;
    })
    .catch(function (error) {
      console.error(error);
    });
  }
  
  
  
  
  export  function getParameterById(recordId) {
    var path = "/business/parameter/getParameterRecordDetail?recordId="+recordId;
    return Vue.$http.get(path)
      .then((res) => {
          return res.data.data;
      })
      .catch(function (error) {
        console.error(error);
      });
  }


export  function getParameterList(recordName, recordStartTime, recordEndTime, pageNum ,pageSize) {

  var path = "/business/parameter/getParameterRecordList";
  return Vue.$http.post(path, {
    recordName: recordName,
    recordStartTime: recordStartTime,
    recordEndTime: recordEndTime,
    pageNum: pageNum==null?0:pageNum,
    pageSize: pageSize==null?10:pageSize
    })
    .then((res) => {
        return res.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}

export  function getDeviceOptionsData(positionId, deviceName) {
  var path = "/business/device/getDeviceListForInsertRecord";
  return Vue.$http.post(path, {
    position : positionId,
    name: deviceName
    })
    .then((res) => {
        return res.data.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}



